<template>
  <div>
    <el-form ref="systemFrom" :model="temp" :rules="rules" label-position="top">
      <el-row :gutter="10">
        <el-col :span="8">
          <el-form-item label="数据字典版本号" prop="dictionaryDataVersion">
            <el-input v-model.trim="temp.dictionaryDataVersion"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="数据库备份路径" prop="databaseBackupPath">
            <el-input v-model.trim="temp.databaseBackupPath"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="24">
          <el-form-item label="mysql可执行bin文件的父文件夹路径" prop="mysqlBinParentPath" label-width="260px">
            <el-input v-model.trim="temp.mysqlBinParentPath"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'System',
  props: {
    systemData: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      temp: {
        dictionaryDataVersion: '',
        paymentLogTimeout: '',
        receiverExAcctNo: '',
        databaseBackupPath: '',
        mysqlBinParentPath: ''
      },
      rules: {
        dictionaryDataVersion: [
          { required: true, message: '请输入数据字典版本号', trigger: 'blur' }
        ],
        paymentLogTimeout: [
          { required: true, message: '请输入支付记录过期时间 (秒)', trigger: 'blur' }
        ],
        receiverExAcctNo: [
          { required: true, message: '请输入平台收款人账户', trigger: 'blur' }
        ],
        databaseBackupPath: [
          { required: true, message: '请输入数据库备份路径', trigger: 'blur' }
        ],
        mysqlBinParentPath: [
          { required: true, message: '请输入mysql可执行bin文件的父文件夹路径', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    systemData(newData) {
      this.copyTemp()
    }
  },
  created() {
    this.copyTemp()
  },
  methods: {

    // 初始化数据
    copyTemp() {
      for (var key in this.temp) {
        this.temp[key] = this.systemData[key]
      }
    },

    // 表单验证
    verifyData() {
      var v = false
      this.$refs['systemFrom'].validate((valid) => {
        v = valid
      })
      return v
    },

    // 验证通过后 调用此方法 返回数据
    returnData() {
      return this.temp
    }
  }
}
</script>

<style scoped>

</style>
